home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 353_01 / intro.txt < prev    next >
Text File  |  1992-01-18  |  12KB  |  294 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                                                      Introduction
  8.                                                       WHAT IS C++
  9.  
  10.  
  11. THE ORIGIN OF C++
  12. _________________________________________________________________
  13.  
  14. The C programming language was developed at AT&T for the purpose
  15. of writing the operating system for the PDP-11 series of computers
  16. which ultimately became the unix operating system.  C was developed
  17. with the primary goal of operating efficiency.  Bjarne Stroustrup,
  18. also of AT&T, developed C++ in order to add object oriented
  19. constructs to the C language.  Because object oriented technology
  20. was new at the time and all existing implementations of object
  21. oriented languages were very slow and inefficient, the primary goal
  22. of C++ was to maintain the efficiency of C.
  23.  
  24. C++ can be viewed as a procedural language with some additional
  25. constructs, some of which are added for object oriented programming
  26. and some for improved procedural syntax.  A well written C++
  27. program will reflect elements of both object oriented programming
  28. style and classic procedural programming.  C++ is actually an
  29. extendible language since we can define new types in such a way
  30. that they act just like the predefined types which are part of the
  31. standard language.  C++ is designed for large scale software
  32. development.
  33.  
  34.  
  35.  
  36. HOW TO GET STARTED IN C++
  37. _________________________________________________________________
  38.  
  39. The C programming language was originally defined by the classic
  40. text authored by Kernigan and Ritchie, "The C Programming
  41. language", and was the standard used by all C programmers until a
  42. few years ago.  The ANSI standard for C was finally approved in
  43. December of 1989 and has become the official standard for
  44. programming in C.  Since the ANSI standard adds many things to the
  45. language which were not a part of the Kernigan and Ritchie
  46. definition, and changes a few, the two definitions are not
  47. absolutely compatible and some experienced C programmers may not
  48. have studied the newer constructs added to the language by the
  49. ANSI-C standard.
  50.  
  51.  
  52. This tutorial will assume a thorough knowledge of the C programming
  53. language and little time will be spent on the fundamental aspects
  54. of the language.  However, because we realize that many programmers
  55. have learned the dialect of C as defined by Kernigan & Ritchie,
  56. some sections will be devoted to explaining the newer additions as
  57.  
  58.                                                          Page I-1
  59.  
  60.                                        Introduction - What is C++
  61.  
  62. provided by the ANSI-C standard.  As the ANSI-C standard was in
  63. development, many of the newer constructs from C++ were included
  64. as parts of C itself, so even though C++ is a derivation and
  65. extension of C, it would be fair to say that ANSI-C has some of its
  66. roots in C++.  An example is prototyping which was developed for
  67. C++ and later added to C.
  68.  
  69. The best way to learn C++ is by using it.  Almost any valid C
  70. program is also a valid C++ program, and in fact the addition of
  71. about 12 keywords is the only reason that some C programs will not
  72. compile and execute as a C++ program.  There are a few other subtle
  73. differences but we will save the discussion of them until later.
  74. Since this is true, the best way to learn C++ is to simply add to
  75. your present knowledge and use a few new constructs as you need
  76. them for each new program.  It would be a tremendous mistake to try
  77. to use all of the new constructs in your first C++ program.  You
  78. would probably end up with an incomprehensive mixture of code that
  79. would be more inefficient than the same program written purely in
  80. C.  It would be far better to add a few new constructs to your
  81. toolkit each day, and use them as needed while you gain experience
  82. with their use.
  83.  
  84. As an illustration of the portability of C to C++, all of the
  85. example programs included in the Coronado Enterprises C tutorial
  86. compile and execute correctly when compiled as C++ programs with
  87. no changes.  None of the C++ programs will compile and execute
  88. correctly with any C compiler however, if for no other reason than
  89. the use of the new style of C++ comments.
  90.  
  91.  
  92.  
  93. HOW TO USE THIS TUTORIAL
  94. _________________________________________________________________
  95.  
  96. This tutorial is best used while sitting in front of your computer.
  97. It is designed to help you gain experience with your own C++
  98. compiler in addition to teaching you the proper use of C++.
  99. Display an example program on the monitor, using whatever text
  100. editor you usually use, and read the accompanying text which will
  101. describe each new construct introduced in the example program.
  102. After you study the program, and understand the new constructs,
  103. compile and execute the program with your C++ compiler.
  104.  
  105. After you successfully compile and execute the example program,
  106. introduce a few errors into the program to see what kind of error
  107. messages are issued.  If you have done much programming, you will
  108. not be surprised if your compiler gives you an error message that
  109. seems to have nothing to do with the error introduced.  This is
  110. because error message analysis is a very difficult problem with any
  111. modern programming language.  The most important result of these
  112. error introduction exercises is the experience you will gain using
  113. your compiler and understanding its nuances.  You should then
  114. attempt to extend the program using the techniques introduced with
  115. the program to gain experience.
  116.  
  117.                                                          Page I-2
  118.  
  119.                                        Introduction - What is C++
  120.  
  121.  
  122. In the text of this tutorial, keywords, variable names, and
  123. function names will be written in bold type as an aid when you are
  124. studying the example programs.
  125.  
  126. The way this tutorial is written, you will not find it necessary
  127. to compile and execute every program.  At the end of each example
  128. program, listed in comments, you will find the result of execution
  129. of that program.  Some of the constructs are simple and easy for
  130. you to understand, so you may choose to ignore compilation and
  131. execution of that example program, depending upon the result of
  132. execution to give you the output.  Some students have used these
  133. results of execution to study several chapters of this tutorial on
  134. an airplane by referring to a hardcopy of the example programs.
  135.  
  136.  
  137. DIFFERENT C++ IMPLEMENTATIONS
  138. _________________________________________________________________
  139.  
  140. There are primarily two standards for naming C++ files, one using
  141. the extension CPP and the other using the extension CXX.  All files
  142. in this tutorial use the CPP extension for naming files.  If your
  143. compiler requires the CXX extension it will be up to you to rename
  144. the files.  When C++ was in its infancy, header files generally
  145. used the extension .HPP, but there is a definite trend to use .H
  146. for all header files.  For that reason all header files in this
  147. tutorial will use that convention.
  148.  
  149. Even though we have tried to use the most generic form of all
  150. constructs, it is possible that some constructs will not actually
  151. compile and run with some C++ compilers.  As we find new
  152. implementations of C++, and acquire copies of them, we will compile
  153. and execute all files in an attempt to make all example programs
  154. as universal as possible.
  155.  
  156. The C++ language is very new and is changing rapidly.  The
  157. developer of the language, AT&T, has changed the formal definition
  158. several times in the last few years and the compiler writers are
  159. staying busy trying to keep up with them.  It would be best for you
  160. to search the more popular programming languages for evaluations
  161. and comparisons of compilers.  New C++ implementations are being
  162. introduced at such a rapid rate, that we cannot make a compiler
  163. recommendation here.
  164.  
  165.  
  166. PRINTING OUT THE EXAMPLE PROGRAMS
  167. _________________________________________________________________
  168.  
  169. Some students prefer to work from a hardcopy of the example
  170. programs.  If you desire to print out the example programs, there
  171. is a batch file on the distribution disk to help you do this.  Make
  172. the distribution disk the defaul